package com.scuec.demo1.mapper;  // 修改包名

import com.scuec.demo1.entity.StudentInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentMapper {

    @Select("SELECT * FROM student_info")
    List<StudentInfo> getStudentInfo();

    @Select("SELECT * FROM student_info WHERE stuid = #{id}")
    StudentInfo getStudentInfoById(Integer id);

    @Delete("DELETE FROM student_info WHERE stuid = #{id}")
    int deleteStudentInfoById(Integer id);

    @Insert("INSERT INTO student_info (stu_no, stu_name, stu_sex, stu_phone,stu_birthday, stu_education, stu_interest,my_color, lucky_number,create_date, clsid) " +
            "VALUES (#{stu_no}, #{stu_name}, #{stu_sex},#{stu_phone}, #{stu_birthday}, #{stu_education},#{stu_interest}, #{my_color}, #{lucky_number},NOW(), #{clsid})")
    @Options(useGeneratedKeys = true, keyProperty = "stuid")
    int insertStudentInfo(StudentInfo studentInfo);

    // StudentMapper.java
    @Update("UPDATE student_info SET " +
            "stu_no = #{stu_no}, " +
            "stu_name = #{stu_name}, " +
            "stu_sex = #{stu_sex}, " +
            "stu_phone = #{stu_phone}, " +
            "stu_birthday = #{stu_birthday}, " +
            "stu_education = #{stu_education}, " +
            "stu_interest = #{stu_interest}, " +
            "my_color = #{my_color}, " +
            "lucky_number = #{lucky_number}, " +
            "clsid = #{clsid} " +
            "WHERE stuid = #{stuid}")
    int updateStudentInfo(StudentInfo studentInfo);

}
